@extends('admin.main')
@section('content')
    <div class="admin-biaogelist">
        <div class="daohang">
            <ul>
                <li>
                    <button type="button" class="am-btn am-btn-default am-radius am-btn-xs">评价管理>
                    </button>
                </li>
            </ul>
        </div>
        <div class="listbiaoti am-cf">
            <ul class="am-icon-flag on"> 评价审核</ul>

            <dl class="am-icon-home" style="float: right;"> 当前位置： 首页 > <a href="#">评价列表</a></dl>

        </div>

        <form class="am-form am-g">
            <table width="100%" class="am-table am-table-bordered am-table-radius am-table-striped">
                <thead>
                <tr class="am-success">
                    <th class="table-id">ID</th>
                    <th class="table-title">医师</th>
                    <th class="table-type">评论内容</th>
                    <th class="table-author">评价者</th>
                    <th class="table-date am-hide-sm-only">修改日期</th>
                    <th width="163px" class="table-set">操作</th>
                </tr>
                </thead>
                <tbody>
                @if(!empty($res['data']))
                    @foreach($res['data'] as $v)
                        <tr>
                            <td>{{$v['id']}}</td>
                            <td><a href="#">{{$v['doctorname']}}</a></td>
                            <td>{{$v['content']}}</td>
                            <td class="am-hide-sm-only">{{$v['username']}}</td>
                            <td class="am-hide-sm-only">{{$v['created_at']}}</td>
                            <td>@if($v['status']==1) 已通过@elseif ($v['status']==2) <span
                                        style="color: #ff6666">未通过</span> @else<a href="javascript:void(0)"
                                                                                  onclick="verify(this,1,{{$v['id']}})"
                                                                                  class="am-icon-check am-text-warning"></a>
                                <a href="javascript:void(0)" onclick="verify(this,2,{{$v['id']}})"
                                   class="am-icon-close am-text-primary"></a> @endif</td>
                        </tr>
                    @endforeach
                @else
                    <tr><td colspan="5" align="center">暂无数据</td></tr>
                @endif
                </tbody>
            </table>
        </form>
        @if(!empty($res['data']))
        <ul class="am-pagination am-fr">
            @if(isset($res['prev_page_url']))
                <li><a href="$res['prev_page_url']">«</a></li>
            @endif
            @foreach($res['pageNoList'] as $v)
                @if($res['current_page']==$v)
                    <li class="am-active"><a href="{{urlAdmin('comment','getCommentList')}}?page={{$v}}">{{$v}}</a></li>
                @else
                    <li><a href="{{urlAdmin('comment','getCommentList')}}?page={{$v}}">{{$v}}</a></li>
                @endif
            @endforeach
                @if(isset($res['next_page_url']))
                    <li><a href="$res['next_page_url']">»</a></li>
                @endif
        </ul>
        @endif
        @include('admin.footer')
        @section('css')
            <link type="text/css" src="/assets/layer/skin/default/layer.css"/>
        @endsection
        @section('js')
            <script type="text/javascript" src="/assets/layer/layer.js"></script>
        @endsection
        @section('script')
            <script>
                function verify(_this, ver, id) {
                    if (ver == 2) {
                        str = '不通过';
                    } else {
                        str = '通过';
                    }
                    layer.confirm('您确定' + str + '吗？', {
                        btn: ['确定', '取消'] //按钮
                    }, function () {
                        $.ajax({
                            type: "post",
                            url: "{{urlAdmin('comment','postEditComment')}}",
                            data: {id: id, state: ver},
                            dataType: "json",
                            success: function (res) {
                                if (res['state'] == 1) {
                                    $parend = _this.parentNode;
                                    if (ver == 2) {
                                        $parend.innerHTML = "<span style='color: #ff6666'>未通过</span>";
                                    } else {
                                        $parend.innerHTML = "通过";
                                    }
                                    layer.msg('操作成功', {icon: 6});
                                } else {
                                    layer.msg('操作失败', {icon: 5});
                                }
                            }
                        })

                    });
                }
            </script>
        @endsection
    </div>
@endsection